package com.jiankang.controller;


import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.jiankang.entity.Homepictures;
import com.jiankang.entity.User;
import com.jiankang.entity.Usercomment;
import com.jiankang.service.HomepicturesService;
import com.jiankang.service.UserService;
import com.jiankang.service.UsercommentService;
import com.jiankang.util.Page;

@Controller
@RequestMapping("/transfer")
public class UsercommentController {
	@Resource
	private UsercommentService usercommentService;
	@Resource
	private HomepicturesService homepicturesService;
	@Resource
	private UserService  userService ;
	@RequestMapping("/usercomment") 
	public String selecthealthcare(Model model, HttpServletRequest req)throws Exception {
		List<User> user=userService.getAllUser();
		List<Homepictures> homepictures=homepicturesService.sickness();
		String pageNow = req.getParameter("pageNow");
		Page page = null;
		List<Usercomment> usercomment=null;
		int totalCount = (int) usercommentService.getAllProductCount();
		if (pageNow != null) {
			page = new Page(totalCount, Integer.parseInt(pageNow));
			usercomment=usercommentService.getHealthFile(page);
		}else{
			page = new Page(totalCount, 1);
			usercomment=usercommentService.getHealthFile(page);
		}
		model.addAttribute("page", page);
		model.addAttribute("usercomment", usercomment);
		model.addAttribute("user", user);
		model.addAttribute("homepictures", homepictures);
		return "admin/usercomment";
		
	}
}
